'use strict';
import { Controller } from 'egg';

export default class CollectionController extends Controller {
  
  public async addFavorites() {
    const { ctx } = this;
    try {
      let res = await ctx.service.collection.addFavorites(ctx.query);
      ctx.success(res, '操作成功');
    } catch (e) {
      console.log(e);
      ctx.error(423, ctx.helper.errorCode[423]);
    }
  }

  public async removeFavorites() {
    const { ctx } = this;
    try {
      let res = await ctx.service.collection.removeFavorites(ctx.query);
      ctx.success(res, '操作成功');
    } catch (e) {
      console.log(e);
      ctx.error(423, ctx.helper.errorCode[423]);
    }
  }
  
  public async isFavorites() {
    const { ctx } = this;
      let res = await ctx.service.collection.isFavorites(ctx.query);
      ctx.success(res);
  }
}
